package com.zh.common.config;

import com.google.common.collect.Maps;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @ProjectName: house-care
 * @Package: com.zh.common.config
 * @ClassName: GlobalConfig
 * @Description: java类作用描述
 * @Author: lds
 * @CreateDate: 2019/5/14 0014 14:03
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/5/14 0014 14:03
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
@Configuration
public class GlobalConfig {

    @Resource
    private Environment env;

    @Resource
    private void configureThymeleafStaticVars(ThymeleafViewResolver viewResolver) {
        if (viewResolver != null) {
            Map<String, Object> vars = Maps.newHashMap();
            vars.put("picUrl", env.getProperty("picUrl"));
            vars.put("webScorkUrl", env.getProperty("webScorkUrl"));
            vars.put("analysis_webSocket_url", env.getProperty("analysis_webSocket_url"));
            vars.put("analysis_api", env.getProperty("analysis_api"));
            viewResolver.setStaticVariables(vars);
        }
    }
}
